package models

import (
	"gitee.com/tangrx/go-admin/utils"
	"github.com/lunny/log"
)

type SearchForm struct {
	Page PageStruct             `form:"page" json:"page" xml:"page"`
	Form map[string]interface{} `form:"form" json:"form" xml:"form"`
}

func (form *SearchForm) GetStr(key string) string {
	if form.Form == nil {
		return ""
	}
	v, err := form.Form[key]
	if err {
		return v.(string)
	}
	return ""
}

func (form *SearchForm) GetInt(key string) int {
	v, err := form.Form[key]
	log.Println(key, ":", v)
	if err {
		return utils.ToInt(v)
	}
	return 0
}
